﻿import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import QtQuick.Controls 2.12
import QtMultimedia 5.14
import "./preferenceSettings"
import "./components/"
import "./exportReport"

ApplicationWindow {
    id: preferenceSettings
    width: 1600*dp
    height: 960*dp
    minimumWidth: 1600*dp
    minimumHeight: 960*dp
//    maximumWidth: 1900*dp
//    maximumHeight: 1060*dp

    readonly property real dp: config.dp

    modality: Qt.WindowModal

    title: qsTr("偏好设置")
    property int btfl1: 0

    property int curPage: 0     // 0 实验配置 1 维护矫正 2 统计保养 3 网络连接 4 报告文件 5 默认设置 6 更新
    color: "#E0E6E9"

    Config{
        id: config
    }

//    Image {
//        id: bj
//        anchors.fill: parent
//        z:0
//        source: "qrc:/picture/ph_bj.png"
//    }


    Component.onCompleted: {
        // 默认样式设置
        var buttonList = column_button.children;
        for(let i = 0; i < buttonList.length; i ++){
            buttonList[i].height = Qt.binding(function(){ return 55*dp })
            buttonList[i].width = Qt.binding(function(){ return 140*dp })
            buttonList[i].radius = Qt.binding(function(){ return 28*dp })
            buttonList[i].icon_width = Qt.binding(function(){ return 28*dp })
            buttonList[i].icon_height = Qt.binding(function(){ return 28*dp })
            buttonList[i].button_color = "white"
            buttonList[i].button_border = "#CCCCCC"
            buttonList[i].text_color   = "#333333"
            buttonList[i].button_color_select = "#1677FF"
            buttonList[i].button_border_select = "transparent"
            buttonList[i].text_color_select   = "#FFFFFF"
            buttonList[i].button_color_hover = "#1677FF"
            buttonList[i].text_color_hover = "white"
        }
    }

    // 按钮 ==============================================================================================
    Column{
        id: column_button
        x: 75*dp; y: parent.height*0.2
        spacing: 15*dp
        PushButton{
            title: " 实验配置"
            button_icon: "qrc:/picture/preferenceTab/settings0.png"
            button_icon_select: "qrc:/picture/preferenceTab/settings1.png"
            isSelected: curPage === 0
            button_icon_hover: "qrc:/picture/preferenceTab/settings1.png"
            onReleased: {
                curPage = 0
            }
        }
        PushButton{
            title: " 维护校正"
            button_icon: "qrc:/picture/preferenceTab/maintain0.png"
            button_icon_select: "qrc:/picture/preferenceTab/maintain1.png"
            isSelected: curPage === 1
            button_icon_hover: "qrc:/picture/preferenceTab/maintain1.png"
            onReleased: {
                curPage = 1
            }
        }
        PushButton{
            title: " 统计保养"
            button_icon: "qrc:/picture/preferenceTab/statistics0.png"
            button_icon_select: "qrc:/picture/preferenceTab/statistics1.png"
            isSelected: curPage === 2
            button_icon_hover: "qrc:/picture/preferenceTab/statistics1.png"
            onReleased: {
                curPage = 2
            }
        }
        PushButton{
            title: " 网络连接"
            button_icon: "qrc:/picture/preferenceTab/net0.png"
            button_icon_select: "qrc:/picture/preferenceTab/net1.png"
            isSelected: curPage === 3
            button_icon_hover: "qrc:/picture/preferenceTab/net1.png"
            onReleased: {
                curPage = 3
            }
        }
        PushButton{
            title: " 语音模块"
            button_icon: "qrc:/picture/preferenceTab/microphone0.png"
            button_icon_select: "qrc:/picture/preferenceTab/microphone1.png"
            isSelected: curPage === 7
            button_icon_hover: "qrc:/picture/preferenceTab/microphone1.png"
            onReleased: {
                curPage = 7
            }
        }
        PushButton{
            title: " 报告文件"
            button_icon: "qrc:/picture/preferenceTab/report0.png"
            button_icon_select: "qrc:/picture/preferenceTab/report1.png"
            isSelected: curPage === 4
            button_icon_hover: "qrc:/picture/preferenceTab/report1.png"
            onReleased: {
                curPage = 4
            }
        }
        PushButton{
            title: " 默认设置"
            button_icon: "qrc:/picture/preferenceTab/default0.png"
            button_icon_select: "qrc:/picture/preferenceTab/default1.png"
            isSelected: curPage === 5
            button_icon_hover: "qrc:/picture/preferenceTab/default1.png"
            onReleased: {
                curPage = 5
            }
        }
        PushButton{
            title: "   更新"
            button_icon: "qrc:/picture/preferenceTab/update0.png"
            button_icon_select: "qrc:/picture/preferenceTab/update1.png"
            isSelected: curPage === 6
            button_icon_hover: "qrc:/picture/preferenceTab/update1.png"
            onReleased: {
                curPage = 6
            }
        }
    }

    // 页面 ========================================================================================
    Item{
        x: 240*dp; y: parent.height*0.1
        width: preferenceSettings.width - x - 100*dp
        height: preferenceSettings.height - parent.height*0.2

        StatMaint {         // 统计保养
            id:staticMaintenance
            width: parent.width;  height:parent.height
            visible: curPage === 2

        }
        BoxExporter {         // 报告文件
            id:reportFile
            width: parent.width;  height:parent.height
            visible: curPage === 4
        }
        DefSet{
            id:defaultSetting
            width: parent.width;  height:parent.height
            visible: curPage === 5
        }
        UpData{
            id:updateSoft
            width: parent.width;  height:parent.height
            visible: curPage === 6
        }
        NetworkConnect{
            id: networkConnections
            width: parent.width;  height:parent.height
            visible: curPage === 3
        }
        ExeSetting{
            id: exeSet
            width: parent.width;  height:parent.height
            visible: curPage === 0
        }
        MaintenanceWin{
            id: mainw
            width: parent.width;  height:parent.height
            visible: curPage === 1
        }
        SpeechMod{
            id: speechmod
            width: parent.width;  height:parent.height
            visible: curPage === 7
        }


    }


    Toast{
        id: toast_settings
        y: 100*dp
        x: parent.width / 2 - 150*dp
        z: 1
    }

}
